package service

import (
	"ruoyi-hello/app/sys/dao"
	"slices"
)

func selectRolePermissionByUserId(userId int) ([]string, []int) {
	sysRoles := dao.SelectRolePermissionByUserId(userId)
	perms := make([]string, len(sysRoles))
	roleIds := make([]int, len(sysRoles))
	if sysRoles != nil && len(sysRoles) > 0 {
		for _, role := range sysRoles {
			if !slices.Contains(perms, role.RoleKey) {
				perms = append(perms, role.RoleKey)
				roleIds = append(roleIds, role.RoleId)
			}
		}
		return perms, roleIds
	}
	return nil, nil
}
